jQuery.noConflict();
(function(jQuery){
    /*
     * check and unchecked all items list
     */
    jQuery.fn.checkAllItems = function(options){
        var checked = jQuery(this).attr('checked');
        if (checked == 'checked') {
        	jQuery('.list_items').each(function(index) {
                jQuery(this).attr('checked','checked');
            });
        } else {
        	jQuery('.list_items').each(function(index) {
                jQuery(this).removeAttr('checked');
            });
        }
    };

    /*
     * bulk Action
     */
    jQuery.fn.bulkAction = function(action){
        switch(action) {
            case 'delete':
                jQuery('#admin_form_list').attr('action', jQuery(this).attr('rel'));
                break;
            case 'published':
                jQuery('#admin_form_list').attr('action', jQuery(this).attr('rel'));
                break;
            case 'unpublished':
                jQuery('#admin_form_list').attr('action', jQuery(this).attr('rel'));
                break;
            default:
                break;
        }
        document.forms.admin_form_list.submit();
    };
    
    /*
     * hash a string
     */
    jQuery.fn.hashString = function(str){
    	var salt = '';
    	jQuery.ajax({
    		 type: "GET",   
	         url: "/admin/auth/get-salt",
	         async: false,
	         cache: false,
	         success : function(text) {
	             var obj = jQuery.parseJSON(text);
	             salt = obj.salt;
	         }
    	});
    	var encrypted = jQuery.base64.encode(String(salt + str));
    	jQuery('#admin_form_login_password').val(encrypted);
    };
})(jQuery);